from scapy.all import *

target='192.168.1.105'

def IP_packet():
    ip_packet=IP(dst='192.168.1.0/24',ttl=80)   
    [print(p.show()) for p in ip_packet]        
    
def Ether_packet():
    packet=Ether(dst="ff:ff:ff:ff:ff:ff")
    print(packet.show())

def HTTP_packet():
    packet=IP()/TCP()/"GET/HTTP/1.0\r\n\r\n"
    print(packet.show())

def view_properites():  # view the packet properites
    print(ls(IP()))

def send_packet():
    result=send(IP(dst=target)/ICMP())  # 工作在第三层
    print(result)

    result=sendp(Ether(dst="ff:ff:ff:ff:ff:ff"))    # 工作在第二层
    print(result)

    fuzzed_packet=IP(dst=target)/fuzz(TCP())
    packet=IP(dst=target)/TCP()
    print(fuzzed_packet.show())
    print('--------------------------------------------------------')
    print(packet.show())
    
def revice_packet():
    # answer,unanswer=sr(IP(dst=target)/ICMP())
    # print(answer.summary())
    # print(unanswer.summary())
    packet=IP(dst=target)/TCP()/"GET/HTTP/1.0\r\n\r\n"
    answer,unanswer=sr(packet)
    print(answer.summary())
    print(unanswer.summary())
revice_packet()